#include "bsp_buzzer.h"
//			   C	 D    E 	F	 G	 A	  B	   C`
//u16 hz[] = {523, 587, 659, 698, 784, 880, 988, 1047};

//            C			D			E			 F			G			A			B		  C`
u16 hz[] = { 1047, 1175, 1319,  1397, 1568, 1760, 1976, 2093 };
// >= 2564

#define PRESCALER  		10

void Buzzer_init() {

}

void Buzzer_beep(u8 hz_val_index) { // 1,2,3,4 ... 7

    u16 hz_val = hz[hz_val_index - 1];
    Buzzer_play(hz_val);
}

void Buzzer_play(u16 hz_val) {

	lib_timer1_update_period(PRESCALER, hz_val);
	lib_timer1_ch1_update(50);
}

void Buzzer_stop() {
	lib_timer1_ch1_update(0);
}